package com.kinyx.framework.utils;

import javax.util.XHashMap;

import org.junit.Assert;
import org.junit.Test;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public class KStringUtils_Tester_replaceEL {

	@Test
	public void test() {
		Assert.assertEquals(null, KStringUtils.replaceEL(null, null));
		Assert.assertEquals(null, KStringUtils.replaceEL("null", null));

		Assert.assertEquals("", KStringUtils.replaceEL("", null));
		Assert.assertEquals(" ", KStringUtils.replaceEL(" ", null));

		Assert.assertEquals(" null ", KStringUtils.replaceEL(" null ", null));
		Assert.assertEquals("foo", KStringUtils.replaceEL("foo", null));
		Assert.assertEquals(" foo ", KStringUtils.replaceEL(" foo ", null));

		Assert.assertEquals("${key}", KStringUtils.replaceEL("${key}", null));
		Assert.assertEquals("foo", KStringUtils.replaceEL("${key}", new XHashMap<String, Object>().xPut("key", "foo")));
		Assert.assertEquals("from foo to ${to}", KStringUtils.replaceEL("from ${from} to ${to}", new XHashMap<String, Object>().xPut("from", "foo")));
		Assert.assertEquals("from ${from} to bar", KStringUtils.replaceEL("from ${from} to ${to}", new XHashMap<String, Object>().xPut("to", "bar")));
		Assert.assertEquals("from foo to bar", KStringUtils.replaceEL("from ${from} to ${to}", new XHashMap<String, Object>().xPut("from", "foo").xPut("to", "bar")));
	}

}
